<template>
  <view class="header-inner" @tap="openBasicParamEditor">
    <view class="u-flex u-row-between">
      <view class="flank-item">
        <view class="over-ellipsis fw-700">
          {{ pickupAddress }}
        </view>
        {{ info.car_use_time | timeFilter }}
      </view>
      <view class="inner-center">
        <view>
          {{ diffTimeStr(info.car_use_time, info.car_return_time) }}
        </view>
      </view>
      <view class="flank-item u-text-right">
        <view class="over-ellipsis fw-700">
          {{ returnAddress }}
        </view>
        {{ info.car_return_time | timeFilter }}
      </view>
    </view>
    <slot />
  </view>
</template>
<script>
import { diffTimeStr } from "@/utils/index.js";
import dayjs from "dayjs";
export default {
  name: "rentCarPriceItem",
  props: {
    info: {
      type: Object,
      default: () => {
        return {};
      },
    },
    pickUpCarType: String,
    pickUpCarTypeName: String,
  },
  filters: {
    // 日期 filter
    timeFilter(val) {
      return val ? dayjs(val).format("MM月DD日 HH:mm") : val;
    },
  },
  computed: {
    pickupAddress() {
      // 用户到店取还车取门店地址，否则取搜索地址
      if (this.pickUpCarType == 3) {
        return this.info.pick_up_store.address
      } else {
        return this.info.pick_up_info.name
      }
    },
    returnAddress() {
      // 用户到店取还车取门店地址，否则取搜索地址
      if (this.pickUpCarType == 3) {
        return this.info.return_store.address
      } else {
        return this.info.return_info.name
      }
    }
  },
  methods: {
    diffTimeStr,
  },
  created() {
  }
};
</script>
<style lang="less" scoped>
.header-inner {
  background: #f6f7fb;
  padding: 24rpx 32rpx;

  .inner-center {
    margin: 0 32rpx;
    text-align: center;
    font-size: 22rpx;
    line-height: 18rpx;

    .change-btn {
      font-weight: 500;
      color: #2f86f6;
    }
    .change-icon {
      width: 48rpx;
      height: 8rpx;
    }
  }

  .flank-item {
    flex: 1;
    overflow: hidden;
    font-size: 24rpx;
    color: #55585f;
    line-height: 34rpx;
    .fw-700 {
      font-weight: 700;
      color: #212329;
    }
  }
}
</style>
